package com.zcy.cmn.controller;

import com.atguigu.yygh.model.cmn.Dict;
import com.zcy.cmn.service.DictService;
import com.zcy.yygh.common.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.Servlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@Api("数据字典")
@CrossOrigin
public class DictController {
    @Autowired
    DictService dictService;
    @GetMapping("/getDictById/{id}")
    @ApiOperation("根据id查")
    public Result getDictById(@PathVariable("id") Long id){
        List<Dict> d = dictService.findChlidData(id);
        return Result.ok(d);
    }
    @GetMapping("/exGet")
    public void getex(HttpServletResponse response){
        dictService.exprotData(response);
    }
    @PostMapping("/importDict")
    @ApiOperation(value = "导入")
    public Result importDict(MultipartFile file){
        System.out.println(file+"--------------------------------");
        dictService.importDict(file);
        return  Result.ok();
    }
}
